#include <iostream>
#include <cmath>

using namespace std;

const int N = 5e6 + 10;
int a[N], n, k;

int getrandome(int l, int r)
{
	return a[rand() % (r - l + 1) + l];
}

int quick_select(int left, int right, int k)
{
	if(left >= right) return a[left];
	int p = getrandome(left, right);
	int l = left - 1, r = right + 1, i = left;
	while(i < r)
	{
		if(a[i] < p) swap(a[++l], a[i++]);
		else if(a[i] == p) i++;
		else swap(a[--r], a[i]);
	}
	
	int a = l - left + 1, b = r - 1 - l, c = right - r + 1;
	if(k <= a) return quick_select(left, l, k);
	else if(k <= a + b) return p;
	else return quick_select(r, right, k - a - b);
}

int main()
{
	scanf("%d %d", &n, &k);
	k++;
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	
	cout << quick_select(1, n, k) << endl;
	return 0;
}
